home *** CD-ROM | disk | FTP | other *** search
- Path: dispatch.news.demon.net!demon!asta.demon.co.uk
- From: Mark Billingham <mark@astadev.com>
- Newsgroups: comp.lang.c++
- Subject: Templates & Friend classes
- Date: Fri, 29 Mar 1996 18:03:09 +0000
- Organization: Asta Development Corporation
- Message-ID: <315C25DD.4481@astadev.com>
- NNTP-Posting-Host: asta.demon.co.uk
- X-NNTP-Posting-Host: asta.demon.co.uk
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
- MIME-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
-
- How can you make a templated class a friend of a non templated class ?
-
- I have a set of templated array classes which derive from a common base
- class (which is non templated).
-
- Alongside these classes I have have some templated iterators, the non
- templated array base class has member functions which are used only
- by the iterators. I would like to make these function private and allow
- the iterators to access them by making them friends of the array base
- class. But alas, I can't figure out how to do it.
-
-
- to illustate,
-
- class ARRAY_BASE
- {
- friend ??????; // how to make templated class a friend
-
- private:
- UsedByIterators();
- };
-
- template <class T> class ARRAY<T> : public ARRAY_BASE
- {
- ...
- };
-
- template <class T> class ARRAY_ITERATOR
- {
- private:
- ARRAY<T> m_array&;
- bool Next();
- {
- m_array.UsedByIterator(); // Can't its private
- }
- };
-